using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;

namespace COMInstaller
{
    [RunInstaller(true)]
    public partial class COMInstallerCustomAction : Installer
    {
        public COMInstallerCustomAction()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Instala los objetos COM generados por Matlab
        /// </summary>        
        public override void Commit(System.Collections.IDictionary savedState)
        {
            base.Commit(savedState);
        
            if (File.Exists(Context.Parameters["target"] + "PCAEstadistico_1_0.dll"))
            {
                Process processPCAEstadistico = new Process();
                processPCAEstadistico.StartInfo.FileName = "regsvr32";
                processPCAEstadistico.StartInfo.Arguments = "/s \"" + Context.Parameters["target"] + "PCAEstadistico_1_0.dll" + "\"";
                processPCAEstadistico.Start();
            }
            if (File.Exists(Context.Parameters["target"] + "PCANeuronal_1_0.dll"))
            {
                Process processNeuronal = new Process();
                processNeuronal.StartInfo.FileName = "regsvr32";
                processNeuronal.StartInfo.Arguments = "/s \"" + Context.Parameters["target"] + "PCANeuronal_1_0.dll" + "\"";
                processNeuronal.Start();
            }
            if (File.Exists(Context.Parameters["target"] + "MaximumLikelihood_1_0.dll"))
            {
                Process processMaximum = new Process();
                processMaximum.StartInfo.FileName = "regsvr32";
                processMaximum.StartInfo.Arguments = "/s \"" + Context.Parameters["target"] + "MaximumLikelihood_1_0.dll" + "\"";
                processMaximum.Start();
            }
            if (File.Exists(Context.Parameters["target"] + "ConexionesLaterales_1_0.dll"))
            {
                Process processConexiones = new Process();
                processConexiones.StartInfo.FileName = "regsvr32";
                processConexiones.StartInfo.Arguments = "/s \"" + Context.Parameters["target"] + "ConexionesLaterales_1_0.dll" + "\"";
                processConexiones.Start();
            }
        }
    }

}